Description:
SSU detects if a method contains a
case of on a field
of the containing class. A field must be of an integral type; it may
be accessed either directly or via an accessor method. Such
case of
statements should often be replaced with the usage of several subclasses.
Incorrect:
Node = class
private
var kind:integer;
public
procedure print();
end;
...
procedure Node.print();
begin
case kind of
OP_ADD:
...
OP_SUB:
...
end;
end;
Correct:
Node = class abstract
public
procedure print();virtual;abstract;
end;
AddNode = class(Node)
public
procedure print();override;
end;
SubNode = class(Node)
public
procedure print();override;
end;
Refactoring: